package cn.lili.modules.enums;

import java.util.Arrays;

/**
 * @author:xiangqian
 * @date: 2024/3/8 16:05
 */
public enum ReadTypeEnum {

    COMMENT(1, "评价"),
    GIVE(0, "点赞"),
    SHARE(2, "转发"),
    FOLLOW(4, "关注");

    private final Integer code;
    private final String description;

    ReadTypeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ReadTypeEnum getByCode(Integer code) {
        return Arrays.stream(ReadTypeEnum.values())
                .filter(type -> type.getCode().equals(code))
                .findFirst()
                .orElse(null); // 如果找不到对应的枚举值，则返回null或者抛出异常
    }
}
